const mongoose = require('mongoose');
const { ObjectId } = mongoose.Schema;
/**
 * Export model definition object.
 */
module.exports = {
  key: { type: String },
  creatorId: ObjectId,
  projectId: ObjectId,
  oldVersionId: ObjectId,
  rootDirectoryId: ObjectId,
  autoNullCheck: { // 自动空值检查
    type: Boolean,
    default: false,
  },
  currentCommitId: String,
  versionName: String,
  fileRelation: Boolean,
  description: { type: String, default: '' },
  environmentId: { type: [ObjectId], default: [] },
  environmentMacrosShow: { type: Boolean, default: true },
  environmentArgumentsShow: { type: Boolean, default: true },
  // 该字段废弃掉
  system: {
    type: {
      url: String,
      commit: String,
      includes: [String],
    },
  },
  // 编译环境新字段
  /**
   *  [String]: {// 编译环境id
      url: String,
      commit: String,
      includes: [String],
    },
   */
  systems: { type: Object, default: {} },
  environmentChanged: { type: Boolean, default: false },
  status: { type: Number, default: 0 },
  visitAt: Date,
  finishAt: Date,
  headers: { type: Object, default: {} },
  includes: { type: [String], default: [] },
  'include files': { type: [String], default: [] },
  macros: {
    type: [{
      key: String,
      value: String,
    }],
    default: [],
  },
  arguments: { type: [String], default: [] },
  properties: { type: Object, default: {} },
  timeout: { type: Number, default: 10 },
  timeoutTestGen: { type: Number, default: 10 }, // 测试用例生成超时时间设置
  timeoutTestRun: { type: Number, default: 10 }, // 测试用例执行超时时间设置
  extraExit: String,
  coverages: { type: Number, default: 0 },
  caseSensitive: { type: Boolean, default: true },
  systemType: { type: Number, default: 32 },
  autoFill: { type: Boolean, default: false },
  strictOutputCheck: { type: Boolean, default: true },
  repository: {
    type: { type: String, default: 'git' },
    url: String,
  },
  tasks: { type: Object, default: {} },
  // 编译器信息
  'project type': String,
  'ignore asm': { type: Boolean, default: true },
  languages: { type: Object, default: {} },
  language: String,
  environment: String,
  exits: { type: [String], default: [] },
  version: String,
  versionType: {
    type: String,
    enum: ['unitTest', 'staticAnalyze', 'integrationTest'],
    default: 'unitTest',
  },
  testIdentifierRule: { type: Object, default: {} },
  masterVersionId: ObjectId,
  analyzeTemplate: ObjectId,
  // 回归版本操作状态0:未执行回归操作，1：执行回归操作
  regressionStatus: {
    type: Number,
    default: 0,
  },
  eventReminder: {
    // 缺陷数据被清空的状态及原因
    defectsCleared: {
      type: Number,
      default: 0,
    },
    // 配置二次确认
    configConfirmed: {
      type: Boolean,
      default: false,
    },
    // 项目是否解析过
    parsed: {
      type: Boolean,
      default: false,
    },
    // 回归版本状态提示
    regressionStatusPrompt: {
      type: Number,
      default: 0,
    },
    // 首次进入操作
    firstVisit: {
      type: Number,
      default: 0,
    },
  },
  'exclude namespaces': { type: Array, default: [] },
  // 测试用例数据深度
  dataDepth: {
    type: Number,
    default: 6,
  },
  collectCoverageKind: { type: Number, default: 1 },
  encoding: String,
  // 全局通过准则
  tolerance: Object,
  // 静态分析当前选中的规则集
  specs: Array,
  mcdcKind: { type: Number, default: 1 },
  // 追溯矩阵显示列设置
  traceabilityMatrix: {
    commonFields: {
      type: Array,
      default: ['fileName', 'functionName', 'testIdentification', 'description', 'requirementInfo', 'typeNumber'],
    },
    userDefinedFields: [String],
  },
  // 默认打桩层级
  stubDepth: Number,
  commandScriptBeforeParse: String,
  commandScriptBeforeExecute: String,
  commandScriptBeforeExport: String,
  onlyReplaceStubFunction: {
    type: Boolean,
    default: false,
  },
  includedHeaders: String, // 预包含头文件
  // 工具内置编译环境
  builtIn: Boolean,
  // 默认编译环境的project types
  projectTypes: Object,
  // 默认编译环境的url
  systemUrl: String,
};
